export function getSessionStorage (key) {
  let data, obj
  try {
    obj = sessionStorage.getItem(key)
    if (typeof obj === 'string') {
      data = JSON.parse(obj)
    } else {
      data = obj
    }
  } catch (e) {
    data = obj
  }
  return data
}

export function setSessionStorage (name, obj) {
  if (typeof obj === 'object') {
    obj = JSON.stringify(obj)
  }
  sessionStorage.setItem(name, obj)
}
export function getLocalStorage (key) {
  let data, obj
  try {
    obj = localStorage.getItem(key)
    if (typeof obj === 'string') {
      data = JSON.parse(obj)
    } else {
      data = obj
    }
  } catch (e) {
    data = obj
  }
  return data
}
export function setLocalStorage (name, obj) {
  if (typeof obj === 'object') {
    obj = JSON.stringify(obj)
  }
  localStorage.setItem(name, obj)
}
